﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using System.Web.Services;
using System.Collections;
using Catering.View_Operaction;
using Catering_DBOpertion;

namespace Catering.Catering_Page.yl.Daily
{
    public partial class pxyj_px : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                DataTable ds_null = null;
                Rep_Plan.DataSource = ds_null;
                Rep_Plan.DataBind();
                txt_stTime.Attributes.Add("onfocus", "WdatePicker({dateFmt:'yyyy/MM/dd'})");
                txt_endTime.Attributes.Add("onfocus", "WdatePicker({dateFmt:'yyyy/MM/dd'})");
                txt_stTime.Text = "全部";
                txt_endTime.Text = "全部";
                LoadDrop();
                LoadForm();
            }
        }
        protected void LoadDrop()
        {
            if (Session["User"] != null)
            {
                string userid = Session["PersonnelID"].ToString();
                int companyid = 0;
                int groupid = 0;
                int classid = 0;
                bool isAdmin = false;
                Bind_Data_to_Controls.GetCompanyByCurrentUser(userid, out companyid, out groupid, out classid, out isAdmin);
                Bind_Data_to_Controls.Bind_Area_ddl(ddl_group, isAdmin, groupid, companyid, true, false);
                Bind_Data_to_Controls.Bind_Class_ddl(ddl_group.SelectedItem, ddl_Class, isAdmin, classid, true);
            }
        }
        protected void ddl_group_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddl_group.SelectedItem != null)
            {
                Bind_Data_to_Controls.Bind_Class_ddl(ddl_group.SelectedItem, ddl_Class);
            }
        }

        protected void Drop_BanZu_SelectedIndexChanged(object sender, EventArgs e)
        {
            //DataTable dt_BanZu = new Catering_Rules.ClassInfo().GetList("AreaID=" + this.Drop_ZuoYeQu.SelectedValue).Tables[0];
            //this.DropBind(this.Drop_BanZu, dt_BanZu, "id", "CName");            
        }
        //公用的DropDownList绑定方法
        public void DropBind(DropDownList drop, DataTable dt, string strValue, string strText)
        {
            drop.Items.Clear();
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ListItem item = new ListItem();
                    item.Text = dt.Rows[i][strText].ToString();
                    item.Value = dt.Rows[i][strValue].ToString();
                    drop.Items.Add(item);
                }
            }
        }
        public DataSet SelTJRByDateAndClassID(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 RID");
            strSql.Append(" FROM DailyManagement ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }
        public DataSet SelPNameByRID(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 Name");
            strSql.Append(" FROM Personnel ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where id = " + int.Parse(strWhere));
            }
            return DbHelperSQL.Query(strSql.ToString());
        }
        public DataSet SelClassInfoAndClassID(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 CName,AreaID");
            strSql.Append(" FROM ClassInfo ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where id=" + int.Parse(strWhere));
            }
            return DbHelperSQL.Query(strSql.ToString());
        }
        public void LoadForm()
        {
            Rep_Plan.DataSource = null;
            //string strForSearch = "";
            try
            {
                if (txt_stTime.Text == "全部" && txt_endTime.Text == "全部")
                {
                    if (ddl_Type.SelectedItem.Text == "全部")
                    {
                        DataSet ds = new Catering_Rules.PeiXunQingKuang().GetList("");
                        DataTable dt_Plan = ds.Tables[0];
                        dt_Plan.Columns.Add("tempId");                        
                        dt_Plan.Columns.Add("ClassName");
                        dt_Plan.Columns.Add("ItemsDate");

                        DataTable dt_rowsleft = dt_Plan.Clone();
                        if (ddl_group.SelectedItem.Text == "全部")
                        {
                            for (int i = 0; i < dt_Plan.Rows.Count; i++)
                            {
                                DataRow dr = dt_rowsleft.NewRow();
                                foreach (DataColumn dc in dt_rowsleft.Columns)
                                {
                                    dr[dc.ColumnName] = dt_Plan.Rows[i][dc.ColumnName];
                                }
                                dt_rowsleft.Rows.Add(dr);
                            }
                            for (int i = 0; i < dt_rowsleft.Rows.Count; i++)
                            {
                                DataSet ds_className = SelClassInfoAndClassID(dt_rowsleft.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString());
                                DataTable dt_className = ds_className.Tables[0];
                                dt_rowsleft.Rows[i]["ClassName"] = dt_className.Rows[0]["CName"];
                                dt_rowsleft.Rows[i]["tempId"] = i + 1;
                                dt_rowsleft.Rows[i]["ItemsDate"] = Convert.ToDateTime(dt_rowsleft.Rows[i]["riqi"].ToString()).ToString("yyyy/MM/dd"); 
                                for (int Cols = 0; Cols < dt_rowsleft.Columns.Count; Cols++)
                                {
                                    if (dt_rowsleft.Rows[i][Cols].ToString() == "")
                                        dt_rowsleft.Rows[i][Cols] = "&nbsp";
                                }
                            }
                        }
                        else if (ddl_group.SelectedItem.Text != "全部" && ddl_Class.SelectedItem.Text == "全部")
                        {
                            for (int i = 0; i < dt_Plan.Rows.Count; i++)
                            {
                                DataSet ds_areaid = SelClassInfoAndClassID(dt_Plan.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString());
                                DataTable dt_areaid = ds_areaid.Tables[0];
                                if (dt_areaid.Rows[0]["AreaID"].ToString() == ddl_group.SelectedValue)
                                {
                                    DataRow dr = dt_rowsleft.NewRow();
                                    foreach (DataColumn dc in dt_rowsleft.Columns)
                                    {
                                        dr[dc.ColumnName] = dt_Plan.Rows[i][dc.ColumnName];
                                    }
                                    dt_rowsleft.Rows.Add(dr);
                                }
                            }
                            for (int i = 0; i < dt_rowsleft.Rows.Count; i++)
                            {
                                DataSet ds_className = SelClassInfoAndClassID(dt_rowsleft.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString());
                                DataTable dt_className = ds_className.Tables[0];
                                dt_rowsleft.Rows[i]["ClassName"] = dt_className.Rows[0]["CName"];
                                dt_rowsleft.Rows[i]["tempId"] = i + 1;
                                dt_rowsleft.Rows[i]["ItemsDate"] = Convert.ToDateTime(dt_rowsleft.Rows[i]["riqi"].ToString()).ToString("yyyy/MM/dd");
                                for (int Cols = 0; Cols < dt_rowsleft.Columns.Count; Cols++)
                                {
                                    if (dt_rowsleft.Rows[i][Cols].ToString() == "")
                                        dt_rowsleft.Rows[i][Cols] = "&nbsp";
                                }
                            }
                        }
                        else if (ddl_group.SelectedItem.Text != "全部" && ddl_Class.SelectedItem.Text != "全部")
                        {
                            for (int i = 0; i < dt_Plan.Rows.Count; i++)
                            {
                                if (dt_Plan.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString() == ddl_Class.SelectedValue)
                                {
                                    DataRow dr = dt_rowsleft.NewRow();
                                    foreach (DataColumn dc in dt_rowsleft.Columns)
                                    {
                                        dr[dc.ColumnName] = dt_Plan.Rows[i][dc.ColumnName];
                                    }
                                    dt_rowsleft.Rows.Add(dr);
                                }
                            }
                            for (int i = 0; i < dt_rowsleft.Rows.Count; i++)
                            {
                                DataSet ds_className = SelClassInfoAndClassID(dt_rowsleft.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString());
                                DataTable dt_className = ds_className.Tables[0];
                                dt_rowsleft.Rows[i]["ClassName"] = dt_className.Rows[0]["CName"];
                                dt_rowsleft.Rows[i]["tempId"] = i + 1;
                                dt_rowsleft.Rows[i]["ItemsDate"] = Convert.ToDateTime(dt_rowsleft.Rows[i]["riqi"].ToString()).ToString("yyyy/MM/dd");
                                for (int Cols = 0; Cols < dt_rowsleft.Columns.Count; Cols++)
                                {
                                    if (dt_rowsleft.Rows[i][Cols].ToString() == "")
                                        dt_rowsleft.Rows[i][Cols] = "&nbsp";
                                }
                            }
                        }
                        this.Rep_Plan.DataSource = dt_rowsleft;
                        this.Rep_Plan.DataBind();
                    }
                    else
                    {
                        DataSet ds = new Catering_Rules.PeiXunQingKuang().GetList(" leibie ='" + ddl_Type.SelectedItem.Text + "'");
                        DataTable dt_Plan = ds.Tables[0];
                        dt_Plan.Columns.Add("tempId");                        
                        dt_Plan.Columns.Add("ClassName");
                        dt_Plan.Columns.Add("ItemsDate");

                        DataTable dt_rowsleft = dt_Plan.Clone();
                        if (ddl_group.SelectedItem.Text == "全部")
                        {
                            for (int i = 0; i < dt_Plan.Rows.Count; i++)
                            {
                                DataRow dr = dt_rowsleft.NewRow();
                                foreach (DataColumn dc in dt_rowsleft.Columns)
                                {
                                    dr[dc.ColumnName] = dt_Plan.Rows[i][dc.ColumnName];
                                }
                                dt_rowsleft.Rows.Add(dr);
                            }
                            for (int i = 0; i < dt_rowsleft.Rows.Count; i++)
                            {
                                DataSet ds_className = SelClassInfoAndClassID(dt_rowsleft.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString());
                                DataTable dt_className = ds_className.Tables[0];
                                dt_rowsleft.Rows[i]["ClassName"] = dt_className.Rows[0]["CName"];
                                dt_rowsleft.Rows[i]["tempId"] = i + 1;
                                dt_rowsleft.Rows[i]["ItemsDate"] = Convert.ToDateTime(dt_rowsleft.Rows[i]["riqi"].ToString()).ToString("yyyy/MM/dd");
                                for (int Cols = 0; Cols < dt_rowsleft.Columns.Count; Cols++)
                                {
                                    if (dt_rowsleft.Rows[i][Cols].ToString() == "")
                                        dt_rowsleft.Rows[i][Cols] = "&nbsp";
                                }
                            }
                        }
                        else if (ddl_group.SelectedItem.Text != "全部" && ddl_Class.SelectedItem.Text == "全部")
                        {
                            for (int i = 0; i < dt_Plan.Rows.Count; i++)
                            {
                                DataSet ds_areaid = SelClassInfoAndClassID(dt_Plan.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString());
                                DataTable dt_areaid = ds_areaid.Tables[0];
                                if (dt_areaid.Rows[0]["AreaID"].ToString() == ddl_group.SelectedValue)
                                {
                                    DataRow dr = dt_rowsleft.NewRow();
                                    foreach (DataColumn dc in dt_rowsleft.Columns)
                                    {
                                        dr[dc.ColumnName] = dt_Plan.Rows[i][dc.ColumnName];
                                    }
                                    dt_rowsleft.Rows.Add(dr);
                                }
                            }
                            for (int i = 0; i < dt_rowsleft.Rows.Count; i++)
                            {
                                DataSet ds_className = SelClassInfoAndClassID(dt_rowsleft.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString());
                                DataTable dt_className = ds_className.Tables[0];
                                dt_rowsleft.Rows[i]["ClassName"] = dt_className.Rows[0]["CName"];
                                dt_rowsleft.Rows[i]["tempId"] = i + 1;
                                dt_rowsleft.Rows[i]["ItemsDate"] = Convert.ToDateTime(dt_rowsleft.Rows[i]["riqi"].ToString()).ToString("yyyy/MM/dd");
                                for (int Cols = 0; Cols < dt_rowsleft.Columns.Count; Cols++)
                                {
                                    if (dt_rowsleft.Rows[i][Cols].ToString() == "")
                                        dt_rowsleft.Rows[i][Cols] = "&nbsp";
                                }
                            }
                        }
                        else if (ddl_group.SelectedItem.Text != "全部" && ddl_Class.SelectedItem.Text != "全部")
                        {
                            for (int i = 0; i < dt_Plan.Rows.Count; i++)
                            {
                                if (dt_Plan.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString() == ddl_Class.SelectedValue)
                                {
                                    DataRow dr = dt_rowsleft.NewRow();
                                    foreach (DataColumn dc in dt_rowsleft.Columns)
                                    {
                                        dr[dc.ColumnName] = dt_Plan.Rows[i][dc.ColumnName];
                                    }
                                    dt_rowsleft.Rows.Add(dr);
                                }
                            }
                            for (int i = 0; i < dt_rowsleft.Rows.Count; i++)
                            {
                                DataSet ds_className = SelClassInfoAndClassID(dt_rowsleft.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString());
                                DataTable dt_className = ds_className.Tables[0];
                                dt_rowsleft.Rows[i]["ClassName"] = dt_className.Rows[0]["CName"];
                                dt_rowsleft.Rows[i]["tempId"] = i + 1;
                                dt_rowsleft.Rows[i]["ItemsDate"] = Convert.ToDateTime(dt_rowsleft.Rows[i]["riqi"].ToString()).ToString("yyyy/MM/dd");
                                for (int Cols = 0; Cols < dt_rowsleft.Columns.Count; Cols++)
                                {
                                    if (dt_rowsleft.Rows[i][Cols].ToString() == "")
                                        dt_rowsleft.Rows[i][Cols] = "&nbsp";
                                }
                            }
                        }
                        this.Rep_Plan.DataSource = dt_rowsleft;
                        this.Rep_Plan.DataBind();
                    }

                }
                else if (txt_stTime.Text != "全部" && txt_endTime.Text != "全部")
                {
                    if (ddl_Type.SelectedItem.Text == "全部")
                    {
                        DataSet ds = new Catering_Rules.PeiXunQingKuang().GetList(" riqi between '" + Convert.ToDateTime(txt_stTime.Text).ToShortDateString() + "' and '" + Convert.ToDateTime(txt_endTime.Text).ToShortDateString() + "'");
                        DataTable dt_Plan = ds.Tables[0];
                        dt_Plan.Columns.Add("tempId");                        
                        dt_Plan.Columns.Add("ClassName");
                        dt_Plan.Columns.Add("ItemsDate");

                        DataTable dt_rowsleft = dt_Plan.Clone();
                        if (ddl_group.SelectedItem.Text == "全部")
                        {
                            for (int i = 0; i < dt_Plan.Rows.Count; i++)
                            {
                                DataRow dr = dt_rowsleft.NewRow();
                                foreach (DataColumn dc in dt_rowsleft.Columns)
                                {
                                    dr[dc.ColumnName] = dt_Plan.Rows[i][dc.ColumnName];
                                }
                                dt_rowsleft.Rows.Add(dr);
                            }
                            for (int i = 0; i < dt_rowsleft.Rows.Count; i++)
                            {
                                DataSet ds_className = SelClassInfoAndClassID(dt_rowsleft.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString());
                                DataTable dt_className = ds_className.Tables[0];
                                dt_rowsleft.Rows[i]["ClassName"] = dt_className.Rows[0]["CName"];
                                dt_rowsleft.Rows[i]["tempId"] = i + 1;
                                dt_rowsleft.Rows[i]["ItemsDate"] = Convert.ToDateTime(dt_rowsleft.Rows[i]["riqi"].ToString()).ToString("yyyy/MM/dd");
                                for (int Cols = 0; Cols < dt_rowsleft.Columns.Count; Cols++)
                                {
                                    if (dt_rowsleft.Rows[i][Cols].ToString() == "")
                                        dt_rowsleft.Rows[i][Cols] = "&nbsp";
                                }
                            }
                        }
                        else if (ddl_group.SelectedItem.Text != "全部" && ddl_Class.SelectedItem.Text == "全部")
                        {
                            for (int i = 0; i < dt_Plan.Rows.Count; i++)
                            {
                                DataSet ds_areaid = SelClassInfoAndClassID(dt_Plan.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString());
                                DataTable dt_areaid = ds_areaid.Tables[0];
                                if (dt_areaid.Rows[0]["AreaID"].ToString() == ddl_group.SelectedValue)
                                {
                                    DataRow dr = dt_rowsleft.NewRow();
                                    foreach (DataColumn dc in dt_rowsleft.Columns)
                                    {
                                        dr[dc.ColumnName] = dt_Plan.Rows[i][dc.ColumnName];
                                    }
                                    dt_rowsleft.Rows.Add(dr);
                                }
                            }
                            for (int i = 0; i < dt_rowsleft.Rows.Count; i++)
                            {
                                DataSet ds_className = SelClassInfoAndClassID(dt_rowsleft.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString());
                                DataTable dt_className = ds_className.Tables[0];
                                dt_rowsleft.Rows[i]["ClassName"] = dt_className.Rows[0]["CName"];
                                dt_rowsleft.Rows[i]["tempId"] = i + 1;
                                dt_rowsleft.Rows[i]["ItemsDate"] = Convert.ToDateTime(dt_rowsleft.Rows[i]["riqi"].ToString()).ToString("yyyy/MM/dd");
                                for (int Cols = 0; Cols < dt_rowsleft.Columns.Count; Cols++)
                                {
                                    if (dt_rowsleft.Rows[i][Cols].ToString() == "")
                                        dt_rowsleft.Rows[i][Cols] = "&nbsp";
                                }
                            }
                        }
                        else if (ddl_group.SelectedItem.Text != "全部" && ddl_Class.SelectedItem.Text != "全部")
                        {
                            for (int i = 0; i < dt_Plan.Rows.Count; i++)
                            {
                                if (dt_Plan.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString() == ddl_Class.SelectedValue)
                                {
                                    DataRow dr = dt_rowsleft.NewRow();
                                    foreach (DataColumn dc in dt_rowsleft.Columns)
                                    {
                                        dr[dc.ColumnName] = dt_Plan.Rows[i][dc.ColumnName];
                                    }
                                    dt_rowsleft.Rows.Add(dr);
                                }
                            }
                            for (int i = 0; i < dt_rowsleft.Rows.Count; i++)
                            {
                                DataSet ds_className = SelClassInfoAndClassID(dt_rowsleft.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString());
                                DataTable dt_className = ds_className.Tables[0];
                                dt_rowsleft.Rows[i]["ClassName"] = dt_className.Rows[0]["CName"];
                                dt_rowsleft.Rows[i]["tempId"] = i + 1;
                                dt_rowsleft.Rows[i]["ItemsDate"] = Convert.ToDateTime(dt_rowsleft.Rows[i]["riqi"].ToString()).ToString("yyyy/MM/dd");
                                for (int Cols = 0; Cols < dt_rowsleft.Columns.Count; Cols++)
                                {
                                    if (dt_rowsleft.Rows[i][Cols].ToString() == "")
                                        dt_rowsleft.Rows[i][Cols] = "&nbsp";
                                }
                            }
                        }
                        this.Rep_Plan.DataSource = dt_rowsleft;
                        this.Rep_Plan.DataBind();
                    }
                    else
                    {
                        DataSet ds = new Catering_Rules.PeiXunQingKuang().GetList(" PType ='" + ddl_Type.SelectedItem.Text + "' and riqi between '" + Convert.ToDateTime(txt_stTime.Text).ToShortDateString() + "' and '" + Convert.ToDateTime(txt_endTime.Text).ToShortDateString() + "'");
                        DataTable dt_Plan = ds.Tables[0];
                        dt_Plan.Columns.Add("tempId");                        
                        dt_Plan.Columns.Add("ClassName");
                        dt_Plan.Columns.Add("ItemsDate");

                        DataTable dt_rowsleft = dt_Plan.Clone();
                        if (ddl_group.SelectedItem.Text == "全部")
                        {
                            for (int i = 0; i < dt_Plan.Rows.Count; i++)
                            {
                                DataRow dr = dt_rowsleft.NewRow();
                                foreach (DataColumn dc in dt_rowsleft.Columns)
                                {
                                    dr[dc.ColumnName] = dt_Plan.Rows[i][dc.ColumnName];
                                }
                                dt_rowsleft.Rows.Add(dr);
                            }
                            for (int i = 0; i < dt_rowsleft.Rows.Count; i++)
                            {
                                DataSet ds_className = SelClassInfoAndClassID(dt_rowsleft.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString());
                                DataTable dt_className = ds_className.Tables[0];
                                dt_rowsleft.Rows[i]["ClassName"] = dt_className.Rows[0]["CName"];
                                dt_rowsleft.Rows[i]["tempId"] = i + 1;
                                dt_rowsleft.Rows[i]["ItemsDate"] = Convert.ToDateTime(dt_rowsleft.Rows[i]["riqi"].ToString()).ToString("yyyy/MM/dd");
                                for (int Cols = 0; Cols < dt_rowsleft.Columns.Count; Cols++)
                                {
                                    if (dt_rowsleft.Rows[i][Cols].ToString() == "")
                                        dt_rowsleft.Rows[i][Cols] = "&nbsp";
                                }
                            }
                        }
                        else if (ddl_group.SelectedItem.Text != "全部" && ddl_Class.SelectedItem.Text == "全部")
                        {
                            for (int i = 0; i < dt_Plan.Rows.Count; i++)
                            {
                                DataSet ds_areaid = SelClassInfoAndClassID(dt_Plan.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString());
                                DataTable dt_areaid = ds_areaid.Tables[0];
                                if (dt_areaid.Rows[0]["AreaID"].ToString() == ddl_group.SelectedValue)
                                {
                                    DataRow dr = dt_rowsleft.NewRow();
                                    foreach (DataColumn dc in dt_rowsleft.Columns)
                                    {
                                        dr[dc.ColumnName] = dt_Plan.Rows[i][dc.ColumnName];
                                    }
                                    dt_rowsleft.Rows.Add(dr);
                                }
                            }
                            for (int i = 0; i < dt_rowsleft.Rows.Count; i++)
                            {
                                DataSet ds_className = SelClassInfoAndClassID(dt_rowsleft.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString());
                                DataTable dt_className = ds_className.Tables[0];
                                dt_rowsleft.Rows[i]["ClassName"] = dt_className.Rows[0]["CName"];
                                dt_rowsleft.Rows[i]["tempId"] = i + 1;
                                dt_rowsleft.Rows[i]["ItemsDate"] = Convert.ToDateTime(dt_rowsleft.Rows[i]["riqi"].ToString()).ToString("yyyy/MM/dd");
                                for (int Cols = 0; Cols < dt_rowsleft.Columns.Count; Cols++)
                                {
                                    if (dt_rowsleft.Rows[i][Cols].ToString() == "")
                                        dt_rowsleft.Rows[i][Cols] = "&nbsp";
                                }
                            }
                        }
                        else if (ddl_group.SelectedItem.Text != "全部" && ddl_Class.SelectedItem.Text != "全部")
                        {
                            for (int i = 0; i < dt_Plan.Rows.Count; i++)
                            {
                                if (dt_Plan.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString() == ddl_Class.SelectedValue)
                                {
                                    DataRow dr = dt_rowsleft.NewRow();
                                    foreach (DataColumn dc in dt_rowsleft.Columns)
                                    {
                                        dr[dc.ColumnName] = dt_Plan.Rows[i][dc.ColumnName];
                                    }
                                    dt_rowsleft.Rows.Add(dr);
                                }
                            }
                            for (int i = 0; i < dt_rowsleft.Rows.Count; i++)
                            {
                                DataSet ds_className = SelClassInfoAndClassID(dt_rowsleft.Rows[i]["ribaobianhao"].ToString().Split(',')[1].ToString());
                                DataTable dt_className = ds_className.Tables[0];
                                dt_rowsleft.Rows[i]["ClassName"] = dt_className.Rows[0]["CName"];
                                dt_rowsleft.Rows[i]["tempId"] = i + 1;
                                dt_rowsleft.Rows[i]["ItemsDate"] = Convert.ToDateTime(dt_rowsleft.Rows[i]["riqi"].ToString()).ToString("yyyy/MM/dd");
                                for (int Cols = 0; Cols < dt_rowsleft.Columns.Count; Cols++)
                                {
                                    if (dt_rowsleft.Rows[i][Cols].ToString() == "")
                                        dt_rowsleft.Rows[i][Cols] = "&nbsp";
                                }
                            }
                        }
                        this.Rep_Plan.DataSource = dt_rowsleft;
                        this.Rep_Plan.DataBind();
                    }
                }
                else
                {
                    string strMsg = "alert('时间选择请一致，都为时间或都为全部！')";
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "onekey", strMsg, true);
                }
            }
            catch
            {

            }
        }

        protected void Search_Click(object sender, EventArgs e)
        {
            LoadForm();
        }

        protected void Rep_Plan_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "del")
            {
                int delID = Convert.ToInt32(e.CommandArgument);
                if (new Catering_Rules.PeiXunQingKuang().Delete(delID))
                {
                    this.LoadForm();
                }
            }
        }

    }
}